//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "ia\fn_modifyItems.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_object"];
DEFAULT_PARAM(_object,TMF_REGISTER_OBJECT,objNull);

if (IS_GROUP(_object)) then {
	{ [_x] call FFUNC(removeItems);
	} foreach units _object;
} else {
	if (!(isNil "tmf_functions_removefak") && {tmf_functions_removefak == 1}) then { _object removeItem "FirstAidKit"; };
	if (!(isNil "tmf_functions_removenvg") && {tmf_functions_removenvg == 1}) then {
		if ("NVGoggles" in (assigneditems _object)) then {
			_object unlinkItem "NVGoggles";
			//_object removeItem "NVGoggles"; _object unassignItem "NVGoggles";
		} else {
			if ("NVGoggles_OPFOR" in (assigneditems _object)) then {
				_object unlinkItem "NVGoggles_OPFOR";
				//_object removeItem "NVGoggles_OPFOR"; _object unassignItem "NVGoggles_OPFOR";
			} else {
				if ("NVGoggles_INDEP" in (assigneditems _object)) then {
					_object unlinkItem "NVGoggles_INDEP";
					//_object removeItem "NVGoggles_INDEP"; _object unassignItem "NVGoggles_INDEP";
				};
			};
		};
	};
	if (!(isNil "tmf_functions_addnvg") && {tmf_functions_addnvg == 1}) then {
		switch(side _object) do {
			case west : { _object linkItem "NVGoggles"; };
			case east : { _object linkItem "NVGoggles_OPFOR"; };
			case resistance : { _object linkItem "NVGoggles_INDEP"; };
			default { _object linkItem "NVGoggles"; };
		};
	};
	if (!(isNil "tmf_functions_addextrafak") && {tmf_functions_addextrafak == 1}) then { _object addItem "FirstAidKit"; };
	if (!(isNil "tmf_functions_addflashlight") && {tmf_functions_addflashlight == 1}) then {
		_object addPrimaryWeaponItem "acc_flashlight";
		_object enableGunLights "AUTO";
	};
	if (!(isNil "tmf_functions_forceflashlight") && {tmf_functions_forceflashlight == 1}) then {
		_object enableGunLights "forceOn";
	};
	if (!(isNil "tmf_functions_removeradio") && {tmf_functions_removeradio == 1}) then {
		[_object] call FFUNC(removeRadio);
	};
};
TRACE("End");
TMFPROFILERSTOP;